package Demo3;
import Demo2.Booklist;
import java.util.Scanner;

public class Search implements IFuntion{
    @Override
    public void work(Booklist booklist) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入书名：>");
        String bookName = scanner.nextLine();
        //遍历数组
        int sz = booklist.getCount();
        int i = 0;
        for (; i < sz; i++) {
            if(booklist.getBook(i).getName().equals(bookName)){
                break;//找到了
            }
        }
        //找不到
        if(i == sz) System.out.println(bookName + "此书不存在！");
        //找到了，输出展示
        else {
            System.out.print("找到了，书籍信息： ");
            System.out.println(booklist.getBook(i));
        }
    }
}
